import React, { Component } from 'react'

import { Row, Col } from 'antd';

import { RiskCol, RiskC, TitleCol } from '../styled';

import { RECTIFIED_RISK_LIST, RISK_LIST } from '../enum';
import Imgviewer from '@/components/ImgViewer';

export default class RiskList extends Component<any> {

  timeSlice = (value) => {
    return value ? value.slice(0, 10) : ''
  };

  render() {

    const { data = {} } = this.props;

    return (
      <>
        <Row>
          <TitleCol span={24}>隐患已整改</TitleCol>
          <Col span={12}>
            {
              Array.isArray(data) && data.map((item, index) => (
                <RiskC key={index}>
                  {
                    RISK_LIST.map((it, ind) => (
                      <Row key={`sub${ind}`}>
                        <RiskCol span={12}>{it.name}</RiskCol>
                        <RiskCol span={12}>{it.func ? this[it.func](item[it.key]) : item[it.key]}</RiskCol>
                      </Row>
                    ))
                  }
                  <Row style={{ padding: '15px 10px', borderLeft: '1px solid #eee', borderBottom: '1px solid #eee', height: '120px', overflow: 'auto' }}>
                    <p>隐患照片</p>
                    {
                      Array.isArray(item.attachList) && item.attachList.map((it, ind) => (
                        <Col key={ind} span={8} style={{ marginBottom: '10px' }}>
                          <Imgviewer thumbWidth='85px' thumbHeight="85px" url={it} isThumb={true} />
                        </Col>
                      ))
                    }
                  </Row>
                </RiskC>
              ))
            }
          </Col>
          <Col span={12}>
            {
              Array.isArray(data) && data.map((item, index) => (
                <RiskC key={index}>
                  {
                    RECTIFIED_RISK_LIST.map((it, ind) => (
                      <Row key={`sub${ind}`}>
                        <RiskCol span={12}>{it.name}</RiskCol>
                        <RiskCol span={12}>{it.func ? this[it.func](item[it.key]) : item[it.key]}</RiskCol>
                      </Row>
                    ))
                  }
                  <Row style={{ padding: '15px 10px', borderLeft: '1px solid #eee', borderBottom: '1px solid #eee', height: '180px', overflow: 'auto' }}>
                    <p>整改照片</p>
                    {
                      Array.isArray(item.rectifieAttachList) && item.rectifieAttachList.map((it, ind) => (
                        <Col key={ind} span={8} style={{ marginBottom: '10px' }}>
                          <Imgviewer thumbWidth='85px' thumbHeight="85px" url={it} isThumb={true} />
                        </Col>
                      ))
                    }
                  </Row>
                </RiskC>
              ))
            }
          </Col>
        </Row>
      </>
    )
  }
}
